Variable Indirection

Description

Variable indirection refers to the situation when you want to manipulate a variable, but the name of the variable that you want to operate on is stored in another variable. The following session in the Alpha Anywhere Interactive window illustrates the point.

varname = "lastname"
? varname
= "lastname"
? lastname
= 
eval(varname) = "smith"
? lastname
= "smith"

As this example shows, the EVAL() function can be used to accomplish variable indirection. The name of the variable that you want to set is stored in the variable varname. EVAL(varname) returns Lastname, so the statement EVAL(varname) = "smith", is equivalent to lastname = "smith".

See Also